<div class="form-container">
	<form id="form">
		<table class="tableform">
			<tr>
				<th>旧密码：</th>
				<td>
					<input name="oldPassword" class="easyui-validatebox" type="text" data-options="required: true"/>
				</td>
			</tr>
			<tr>
				<th>新密码：</th>
				<td>
					<input id="newPassword" name="newPassword" type="password" class="easyui-validatebox" type="text" data-options="required: true"/>
				</td>
			</tr>
			<tr>
				<th>确认密码：</th>
				<td>
					<input validType="equals[$('#newPassword').val()]" invalidMessage="两次输入密码不匹配" class="easyui-validatebox" type="password" data-options="required:true, prompt: '确认密码'" />
				</td>
			</tr>
		</table>
		<input type="hidden" name="id" value="${(currentUser.id)!}">
		<input type="hidden" name="username" value="${(currentUser.username)!}">
		<input type="hidden" name="userSalt" value="${(currentUser.userSalt)!}">
	</form>
</div>

<script>
	//提交表单数据
	var submitNow = function($d) {
		$.post("${ctx}/manager/changePassword", $("#form").form("getData"), function(result) {
			if (result.status) {
				$.easyui.loaded();
				$d.dialog("close");
				$.messager.alert("成功", result.message, "info", function(){
					$.get("${ctx}/manager/system/user/logout", function() {
	    				window.location.replace("${ctx}/manager/login");
	    			});
				});
			} else {
				$.easyui.loaded();$.messager.alert("错误", result.message, "error");
			}
		}, 'json').error(function() { $.easyui.loaded(); });
	};
	
	//验证表单
	var submitForm = function($d) { 
		if($('#form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			submitNow($d) ;
		}
	};
</script>

